package br.com.jokim.didaque.adapter;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import br.com.jokim.didaque.R;
import br.com.jokim.didaque.model.Apostila;


public class ApostilaAdapter extends ArrayAdapter<Apostila>{

	private List<Apostila> listaApostilas;
	
	public ApostilaAdapter(Context context, int textViewResourceId,	List<Apostila> objects) {
		super(context, textViewResourceId, objects);
		listaApostilas = objects;
	}
	
	public void setListaApostilas(List<Apostila> listaApostilas){
		this.listaApostilas = listaApostilas;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if(convertView == null){
			LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = li.inflate(R.layout.listview_apostila, null);
		}
		
		Apostila a = listaApostilas.get(position);
		
		TextView tvApostila = (TextView)view.findViewById(R.id.tv_apostila);
		tvApostila.setText(a.numero+". "+a.titulo);
		
		return view;
	}
}